//
//  FourSetViewController.m
//  marrymarry
//
//  Created by lsj on 16/10/11.
//  Copyright © 2016年 cf. All rights reserved.
//
static NSString * fourCellID =@"FourSetTableViewCell";
static NSString * goVipCellID = @"GoVipTableViewCell";
#import "FourSetViewController.h"
#import "FourSetTableViewCell.h"
#import "GoVipTableViewCell.h"
#import "FourSetModel.h"
#import "TopUpViewController.h"
@interface FourSetViewController ()
@property (weak, nonatomic) IBOutlet UILabel *myTitileLabel;
@property (weak, nonatomic) IBOutlet UITableView *myTableView;
@property (strong,nonatomic) NSDictionary * myBigDic;
@property (strong,nonatomic) NSDictionary * myUserDic;
@end

@implementation FourSetViewController


-(NSMutableArray *)dataArry
{
    if (!_dataArry) {
        _dataArry = [NSMutableArray new];
    }
    return _dataArry;
}


-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = YES;
    self.navigationController.navigationBar.hidden = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.myBigDic = [NSDictionary new];
    self.myUserDic = [NSDictionary new];
     self.myBigDic = [Tools getValueFromNSUserDefaultsByKey:MY_BIGGEST_INFO_DIC];
    self.myUserDic = self.myBigDic[@"user"];
    if (self.isGifts) {
        self.myTitileLabel.text = @"礼物";
    }else if (self.isOtherHeart)
    {
        self.myTitileLabel.text = @"心动";
    }else if (self.isVister)
    {
        self.myTitileLabel.text = @"访客";
    }else if (self.isMyheart)
    {
        self.myTitileLabel.text = @"足迹";
    }
}

/** 返回上一级 **/
- (IBAction)getBackBtn:(UIButton *)sender {
    [self.navigationController popToRootViewControllerAnimated:YES];
}

#pragma mark UITableViewDatasource,UITableViewDelegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    if (self.dataArry.count>0) {
        
        if ([[NSString stringWithFormat:@"%@",self.myUserDic[MY_VIPSTATUS_KEY]] isEqualToString:@"1"]) {
            return 2;
        }else{
            return 1;
        }

    }else
    {
        return  1;
    }
    
    
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (self.dataArry.count> 0) {
        
            if ([[NSString stringWithFormat:@"%@",self.myUserDic[MY_VIPSTATUS_KEY]] isEqualToString:@"1"]) {
                if (section == 0) {
                return 1;
                }else{
                    return 1;
                }
            }else{
                return self.dataArry.count;
            }
    }else{
        return 1;
    }
    
    
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (indexPath.section == 0 && self.dataArry.count> 0) {
        FourSetTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:fourCellID];
        if (!cell) {
            cell = [[FourSetTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:fourCellID];
            
        }
        if (self.dataArry.count>0) {
            if (self.isGifts)
            {cell.isGifts = YES;
                [cell.watchGiftBtn addTarget:self action:@selector(watchGift:) forControlEvents:UIControlEventTouchUpInside];
            }
            else if (self.isOtherHeart)
            {cell.isOtherHeart =YES;}
            else if (self.isVister)
            {cell.isVister = YES;}
            else if (self.isMyheart)
            {cell.isMyheart = YES;}
            
            [cell loadTheViewWithArry:self.dataArry andIndexPath:indexPath];
            
        }
        
        return cell;
    }else{
        GoVipTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:goVipCellID];
        if (!cell) {
            cell = [[GoVipTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:goVipCellID];
            
        }
        [cell.goAddVipBtn addTarget:self action:@selector(goaddVip:) forControlEvents:UIControlEventTouchUpInside];
        return cell;
    }
    
}




- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 70;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   
    
}

#pragma mark --------- 点击前往查看礼物
-(void)watchGift:(UIButton *)giftBtn
{
    NSLog(@"点击了查看礼物");
}

#pragma mark ----------点击了去加V
-(void)goaddVip:(UIButton *)goAddVBtn
{
    NSLog(@"点击了去加V");
    UIStoryboard * TopUpSB = [UIStoryboard storyboardWithName:@"TopUpViewController" bundle:nil];
    TopUpViewController * TopUpVC  = [TopUpSB instantiateViewControllerWithIdentifier:@"TopUpViewController"];
    self.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:TopUpVC animated:YES];
    
}


#pragma mark --------------网络请求
-(void)requestTheNetWith:(NSArray *)myRequestArry andURL:(NSString *)myurl andDic:(NSDictionary *)myDic andRequestSingStr:(NSString *)SingStr;
{
    if (myRequestArry.count>0) {
        [[LJFNetworkingManager shareManager] POST:myurl upLoadImages:myRequestArry parameters:myDic success:^(id returnData, int code, NSString *msg) {
            NSLog(@"%@",msg);
            
        } failure:^(NSError *error) {
            NSLog(@"失败");
            
        } showHUD:self.view];
        
    }else
    {
        [[LJFNetworkingManager shareManager] POST:myurl parameters:myDic success:^(id returnData, int code, NSString *msg) {
            NSLog(@"%@",msg);
            if ([SingStr isEqualToString:@"lookOtherInfoRequest"]) {
               
            }else if ([SingStr isEqualToString:@"heartRequest"]){
                if (code == 1) {
                    
                }
            }
            
        } failure:^(NSError *error) {
            NSLog(@"%@",error);
        } showHUD:self.view];
        
    }
    
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
